<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
    
        /*
        按下： keydown    keypress
                down在press之前触发
                down事件响应所有案件
                press事件只响应能键入值相关的事件+enter键

        抬起： keyup

        
        */

        document.onkeydown = function() {
            console.log('down');
        }

        document.onkeypress = function() {
            console.log('press');
        }


        document.onkeyup = function() {
            console.log(2);
        }

    </script>
</body>
</html>